import socket
import time
from utils.config import REMINDER_SERVER_IP, REMINDER_SERVER_PORT

def send_reminder_event(event_data):
    """发送提醒事件到TCP服务器"""
    try:
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
            s.connect((REMINDER_SERVER_IP, REMINDER_SERVER_PORT))
            s.sendall(event_data.encode('utf-8'))
            print(f"[NETWORK] Sent reminder: {event_data}")
    except Exception as e:
        print(f"[NETWORK ERROR] Failed to send reminder: {str(e)}")

def send_test_event():
    """发送测试提醒事件（用于验证）"""
    test_event = "TEST_EVENT:10:00:Project Meeting"
    send_reminder_event(test_event)
    time.sleep(1)  # 等待发送完成

if __name__ == "__main__":
    send_test_event()